//
//  HXTFuLiInfoVC.m
//  掌上宏力
//
//  Created by admin on 2017/5/22.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "HXTFuLiInfoVC.h"
#import "HXTFLInfoCell.h"
#import "HXTFLInfoModel.h"
#import "HXTFuLiViewModel.h"


@interface HXTFuLiInfoVC ()

@property (nonatomic,strong) HXTFuLiViewModel *viewModel;

@property (nonatomic,strong) NSMutableArray *datasArr;

@end

@implementation HXTFuLiInfoVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的福利";
}
-(void)getDatasArray{
    [self getDatasArray:^(NSString *page, GetDatas handler) {
        _viewModel = [[HXTFuLiViewModel alloc] init];
//        [_viewModel getHXTFLInfo:handler];
        [_viewModel getHXTFLInfo:^{
            NSLog(@"currentpage -- %ld",self.currentPage);
            if (self.currentPage == 1) {
                _datasArr = [NSMutableArray arrayWithArray:_viewModel.datasArray];
                handler(_viewModel.datasArray);

            }else{
                NSLog(@"cur -- %ld",self.currentPage);
                handler([NSArray array]);
            }
        }];
        
    }];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _datasArr.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 35;
}

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    HXTFLInfoModel *model = _datasArr[section];
    return model.name;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HXTFLInfoCell *cell = [HXTFLInfoCell cellWithTableView:tableView];
    HXTFLInfoModel *model = _datasArr[indexPath.section];
    cell.infoModel = model;
    return cell;
}


@end
